//
//  AppDebug.h
//
//  Created by Evan Xie on 8/3/15.
//  Copyright (c) 2015 Family Wings. All rights reserved.
//

#ifndef AppDebug_h
#define AppDebug_h

#import <objc/runtime.h>

#define AppLogTagDebug   @"DEBUG"
#define AppLogTagError   @"ERROR"
#define AppLogTagInfo    @"INFO"
#define AppLogTagWarning @"WARNING"



#ifdef DEBUG

    #define AppLog(...)                 NSLog(@"[%@] %@ (%s [Line:%d])", AppLogTagDebug, [NSString stringWithFormat:__VA_ARGS__], __FUNCTION__, __LINE__)
    #define AppLogError(...)            NSLog(@"[%@] %@ (%s [Line:%d])", AppLogTagError, [NSString stringWithFormat:__VA_ARGS__], __FUNCTION__, __LINE__)
    #define AppLogInfo(...)             NSLog(@"[%@] %@ (%s [Line:%d])", AppLogTagInfo, [NSString stringWithFormat:__VA_ARGS__], __FUNCTION__, __LINE__)
    #define AppLogWaring(...)           NSLog(@"[%@] %@ (%s [Line:%d])", AppLogTagWarning, [NSString stringWithFormat:__VA_ARGS__], __FUNCTION__, __LINE__)
    #define AppLogOther(logTag, ...)    NSLog(@"[%@] %@ (%s [Line:%d])", logTag, [NSString stringWithFormat:__VA_ARGS__], __FUNCTION__, __LINE__)
    #define AppLogObject(ocObject)      NSLog(@"[Object] %@ (%s [Line:%d])", ocObject, __FUNCTION__, __LINE__)

    #define AppLogCallStack()           { NSArray *stackSymbols = [NSThread callStackSymbols]; NSLog(@"%@", stackSymbols);}

#else

    #define AppLog(...)             while(0) {}
    #define AppLogError(...)        while(0) {}
    #define AppLogInfo(...)         while(0) {}
    #define AppLogWaring(...)       while(0) {}
    #define AppLogOther(...)        while(0) {}
    #define AppLogObject(ocObject)  while(0) {}
    #define AppLogCallStack()       while(0) {}

#endif

// C Way
//#define AppLog(fmt, ...)  do { printf("[%s]" fmt " (%s [Line:%d])", "DEBUG", ##__VA_ARGS__, __func__, __LINE__); } while (0)

#endif
